package cn.itrip.trade.config;






import cn.itrip.trade.exception.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author:小伟

 * @Description:  springboot拦截器

 * @Description: springboot拦截器

 * @Date:2019-12-28 11:27
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {

        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            // 添加拦截器 放掉某些特定不需要验证token的路由
            registry.addInterceptor(new JwtInterceptor()).excludePathPatterns("/auth/api/doregister").excludePathPatterns("/auth/api/ckusr")
                                                         .excludePathPatterns("/auth/api/activate").excludePathPatterns("/auth/api/dologin")
                                                         .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**")
                                                         .excludePathPatterns("/api/area-dic/list").excludePathPatterns("/trade/api/prepay/{orderNo}").excludePathPatterns("/trade/api/return_url")
                                                         .excludePathPatterns("/trade/api/notify_url").excludePathPatterns("http://localhost:3000/#/home?_k=9aasee")
                                                         .excludePathPatterns("/biz/api/hotel/queryhotcity/*").excludePathPatterns("/biz/api/hotel/queryhotelfeature")
                                                         .excludePathPatterns("/search/api/hotellist/searchItripHotelListByHotCity");
        }


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }






}
























